<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="arq" uri="/tld/arquitectura.tld" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="dynamic" uri="/tld/dynamic.tld" %>

<html>
<head>
    <jsp:include page="Head.jsp" />
    <dynamic:background />

    <script type="text/javascript" xml:space="preserve">

        function register()
        {
            if( validateFields() )
            {
                document.forms[0].submit();
            }
        }

        function cancel()
        {
            if( confirm('You will loose the information and will be redirect lo the login page. Are you sure?') )
            {
                document.location = 'login.htm';
            }
        }

        <arq:validateFields>
            <arq:fieldValidation validationType="required" fieldId="entidad.login" fieldAlias="<b><i>Login</i></b>" maxLenght="75" />
            <arq:fieldValidation validationType="required" fieldId="entidad.password" fieldAlias="<b><i>Password</i></b>" maxLenght="75" />
            <arq:fieldValidation validationType="required" fieldId="entidad.email" fieldAlias="<b><i>Email</i></b>" isEmail="true" maxLenght="100" />
        </arq:validateFields>

    </script>

</head>
<body>
<form:form method="post" action="register.htm" onsubmit="return validateFields()">
    <form:hidden path="entidad.id" />
    <br><br><br><br><br><br><br><br><br><br><br><br><br>
    <arq:errors printModel="table" classTable="tablaErrores" visibility="global"/>

    <c:choose>
        <c:when test="${command.entidad.id eq null}">
            <title>New account</title>
        </c:when>
        <c:otherwise>
            <title>Account update</title>
        </c:otherwise>
    </c:choose>
    <table width="40%" align="center">
        <tr align="center">
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td align="right" class="textLogin">Login</td>
            <td align="left">
                <form:errors path="entidad.login" cssClass="campoError"/>
                <form:input path="entidad.login" maxlength="50" cssErrorClass="inputError"/>
            </td>
        </tr>
        <tr>
            <td align="right" class="textLogin">Password</td>
            <td align="left">
                <form:errors path="entidad.password" cssClass="campoError"/>
                <form:password path="entidad.password" cssErrorClass="inputError"/>
            </td>
        </tr>
        <tr>
            <td align="right" class="textLogin">Name</td>
            <td align="left">
                <form:errors path="entidad.name" cssClass="campoError"/>
                <form:input path="entidad.name" cssErrorClass="inputError"/>
            </td>
        </tr>
        <tr>
            <td align="right" class="textLogin">Surname</td>
            <td align="left">
                <form:errors path="entidad.surname" cssClass="campoError"/>
                <form:input path="entidad.surname" cssErrorClass="inputError"/>
            </td>
        </tr>
        <tr>
            <td align="right" class="textLogin">Email</td>
            <td align="left">
                <form:errors path="entidad.email" cssClass="campoError"/>
                <form:input path="entidad.email" cssErrorClass="inputError"/>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
    </table>
    <table width="40%" align="center">
        <tr align="center">
            <td align="center">
                <input style="visibility:hidden" type="submit" name="btnLogin" value="Login" />
            </td>
        </tr>
        <tr align="center">
            <td align="center">
                <dynamic:flashButton text="Create" link="register()" width="160" height="35" />
            </td>
            <td>
                <dynamic:flashButton text="Cancel" link="cancel()" width="160" height="35" />
            </td>
        </tr>
    </table>
    <br>
    <table align="center" width="40%">
        <tr align="center">
            <td><img src="images/google_balls.jpg" alt="Google"/></td>
        </tr>
    </table>
</form:form>
</body>
</html>